/* GUI CONVERTED from reoptr1f.p (converter v1.75) Tue Jun  5 16:00:57 2001 */
/* reoptr1f.p - REPETITIVE LABOR TRANSACTION COMPONENT EDIT                   */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.7.1.2 $                                                           */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.3      LAST MODIFIED: 11/01/95   BY: ais *G0V9*                */
/* REVISION: 8.5      LAST MODIFIED: 02/14/96   BY: tjs *J0CX*                */
/* REVISION: 8.5      LAST MODIFIED: 01/20/97   BY: *H0Q8* Julie Milligan     */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */
/* $Revision: 1.7.1.2 $    BY: Hualin Zhong  DATE: 05/30/01 ECO: *N0YY*          */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/*       THIS IS BASED ON rewois.p                                            */

{mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

define input parameter part like pt_part no-undo.
define output parameter inv-issued like mfc_logical no-undo.

define variable trqty like tr_qty_chg no-undo.
define variable transtype as character format "x(7)" no-undo.
define variable cline like sr_lineid no-undo.

assign
   inv-issued = no
   transtype = "ISS-WO".

mainloop:
for each pk_det no-lock
where pk_user = mfguser
      and pk_part = if part <> "" then part else pk_part
      break by pk_user
      by pk_part
      by pk_loc:
/*GUI*/ if global-beam-me-up then undo, leave.


   if first-of(pk_loc) then
      trqty = 0.

   trqty = trqty + pk_qty.

   if last-of(pk_loc) and trqty <> 0 then do:

      /* GET PART MASTER INFORMATION */
      find pt_mstr where pt_part = pk_part no-lock no-error.

      if available pt_mstr then do:

         cline = "-" + string(pk_part,"x(18)").

         for each sr_wkfl
         where sr_userid = mfguser
               and sr_lineid begins cline
               break by sr_site
               by sr_loc
               by sr_lotser
               by sr_ref:
/*GUI*/ if global-beam-me-up then undo, leave.


            if first-of(sr_ref) then trqty = 0.
            trqty = trqty + sr_qty.

            if last-of(sr_ref) and trqty <> 0 then do:

               {gprun.i ""icedit2.p"" "(transtype,
                                        sr_site,
                                        sr_loc,
                                        pt_part,
                                        sr_lotser,
                                        sr_ref,
                                        trqty,
                                        pt_um,
                                        input """",
                                        input """",
                                        output inv-issued)"}
/*GUI*/ if global-beam-me-up then undo, leave.


               if inv-issued then do:
                  /* UNABLE TO ISSUE OR RECEIVE FOR ITEM. */
                  {pxmsg.i &MSGNUM=161 &ERRORLEVEL=3 &MSGARG1=pt_part}
                  {pxmsg.i &MSGTEXT=" getTermLabel(""SITE"",8)
                                   + "": "" + sr_site
                                   + "" ""
                                   + getTermLabel(""LOCATION"",16)
                                   + "": "" + sr_loc + "" ""
                                   + getTermLabel(""LOT/SERIAL"",15)
                                   + "": "" + sr_lotser + "" ""
                                   + getTermLabel(""REFERENCE"",18)
                                   + "": "" + sr_ref "}.
                  leave mainloop.
               end.

            end. /* last-of(sr_ref) */
         end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* for each sr_wkfl */
      end. /* if available pt_mstr */
   end. /* last-of (pk_loc) */
end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* for each pk_det */
